<%- include('../../common/header.html',{css:'common'}) %>
<%- include('../../common/script-validation.html') %>
<style>
    .datepicker {
        z-index: 9999 !important;
    }
    .data-select {
        display: inline-block;
        width: auto;
    }
    td {
        font-size: 10px;
    }
    .select-batch{
        width: 30px;
        height: 20px !important;
        padding: 0px !important;
        line-height: 20px;
        display: block;
        float: right;
        position: absolute;
        top: 4px;
        right: 0;
        color: #28a3ef;
        cursor: pointer;
        z-index: 9;
        background: #FFF;
        border: 1px solid #cCc !important;
        border-radius: 1px !important;
    }
    .select-batch:hover{
        border: 1px solid #28a3ef !important;
    }
    .select-batch:visited{ border: 1px solid #1a65ef !important;
    }
    .bootstrap-select{
        width: 219px !important;
    }
</style>
<script id="form-select" type="application/xhtml+xml">
<div>
    <div class="form-inline">
        <select style="width: 300px;"
                class="form-control"
                data-size="auto"
                data-live-search="true"
                title="收货仓库"
                id="store"
        >
            <$
            stores.map(function (item) {
            $><option  value="<$=item.id $>"><$=item.name $></option>
            <$});
            $>
        </select>
    </div>
    <table class="table table-none-padding table-bordered" style="margin-bottom: 0;">
        <tr>
            <th>操作</th>
            <th >产品</td>
            <th >批号</td>
            <th >库存</th>
            <th >品质规格</th>
            <th>仓库</th>
            <th>类型</th>
            <th >免费仓储期</th>
            <th >发货数量</th>
        </tr>
        <$
        if(purchase.length){
        purchase.map(function(item,index){
        $>
        <tr>
            <td>
                <input type="checkbox" name="selected<$=item.id$>" data-json="<$=JSON.stringify(item)$>"
                <$ if(selected[item.id]){ $>
                checked
                <$}$>
                />
            </td>
            <td>
                <$=item.goodsName $>
            </td>
            <td>
                <$=item.batchNum $>
            </td>
            <td>
                <$=item.numberReceive>0?floatTool.subtract(floatTool.subtract(item.numberReceive,item.numberSended),item.numberSending):(
                item.type==0?item.number:(floatTool.subtract(floatTool.subtract(item.number,item.numberSended),item.numberSending))) $> 吨
            </td>
            <td><$=item.quality $></td>
            <td><$=item.storeName $></td>
            <td><$=item.type==0?'车号':(item.type==1?'转货权':'介绍信') $></td>
            <td><$=formatDate(item.storeTime) $></td>
            <td><input type="text" class="form-control border-none form-inline" value=" <$ if(selected[item.id]){ $><$=selected[item.id].sendTmp $><$}else{$>0<$}$>"/> 吨</td>
        </tr>
        <$ })}else{
        $> <tr><td colspan="9">没有数据</td></tr> <$
        }
        $>
    </table>
    </div>
</script>
<script type="application/xhtml+xml" id="select-batch">
    <table class="table table-none-padding table-bordered" style="margin-bottom: 0;">
            <tr>
            <th>操作</th>
            <th >产品</td>
            <th >批号</td>
            <th >库存</th>
            <th >品质规格</th>
            <th>仓库</th>
            <th>类型</th>
            <th >免费仓储期</th>
            <th >发货数量</th>
            </tr>
            <$
        if(purchase.length){
    purchase.map(function(item,index){
        $>
        <tr>
        <td>
        <input type="checkbox" name="selected<$=item.id$>" data-json="<$=JSON.stringify(item)$>"
                <$ if(selected[item.id]){ $>
        checked
        <$}$>
        />
        </td>
        <td>
        <$=item.goodsName $>
        </td>
        <td>
        <$=item.batchNum $>
        </td>
        <td>
        <$=item.numberReceive>0?floatTool.subtract(floatTool.subtract(item.numberReceive,item.numberSended),item.numberSending):(
                item.type==0?item.number:(floatTool.subtract(floatTool.subtract(item.number,item.numberSended),item.numberSending))) $> 吨
        </td>
        <td><$=item.quality $></td>
        <td><$=item.storeName $></td>
        <td><$=item.type==0?'车号':(item.type==1?'转货权':'介绍信') $></td>
        <td><$=formatDate(item.storeTime) $></td>
        <td><input type="text" class="form-control border-none form-inline" value="0"/> 吨</td>
                </tr>
                <$ })}else{
        $> <tr><td colspan="9">没有数据</td></tr> <$
        }
    $>
    </table>
</script>

<script id="form-combine" type="application/xhtml+xml">
    <div style="height: 531px;overflow: auto;overflow-y: scroll;">

    <table class="table table-vstriped">
            <tr>
                <th>序号</th>
                <th class="w152">订单单号</td>
                <th class="w100">可发货数量</th>
                <th class="w100">单价</th>
                <th class="w100">品质规格</th>
                <th>销售员</th>
                <th class="w152">下单时间</th>
                <th class="w82">操作</th>
            </tr>
            <$
            orders.map(function(item,index){
            if(!selected[item.id]){
            item.canSendNum = floatTool.subtract(item.number,item.deliverNumber);
            item.sendNum = item.canSendNum;
            item.createAt = formatTime(item.createAt);
            $>
            <tr>
                <td><$=index+1$></td>
                <td><$=item.no $></td>
                <td><$=item.canSendNum $> 吨</td>
                <td><$=item.actualPrice $></td>
                <td><$=item.quality $></td>
                <td><$=item.saleName $></td>
                <td><$=item.createAt $></td>
                <td><input type="checkbox" data-json="<$=JSON.stringify(item)$>"/></td>
            </tr>
            <$}
            })
            $>
        </table>
        <$if((orders.length%15)==0){$>
            <button class="btn btn-warning loading-more" >加载更多</button>
        <$}$>
    </div>
</script>
<script id="template-summary" type="application/xhtml+xml">
    <table class="table table-detail table-vstriped" style="border: none !important;">
        <tr>
            <td class="td-label">客户名称：</td>
            <td class="td-label-value">
                <$=clienteleName $>
                <input type="hidden" value="<$=goodsId $>" name="goodsId"/>
                <input type="hidden" value="" name="storeName"/>
                <input type="hidden" value="" name="storeId"/>
                <input type="hidden" value="<$=goodsName $>" name="goodsName"/>
            </td>
            <td class="td-label">产品：</td>
            <td class="td-label-value">
                <$=goodsName $>
            </td>
        </tr>
        <tr>
            <td class="td-label">联系人：</td>
            <td class="td-label-value">
                <$=clienteleUserName $>
            </td>
            <td class="td-label">联系电话：</td>
            <td class="td-label-value">
                <$=clienteleUserPhone $>
            </td>
        </tr>
    </table>
</script>
<script id="template-order-item" type="application/xhtml+xml">
    <tr class="class-<$=id$>" >
        <td>
            <$=no $>
        </td>
        <td>
            <$=canSendNum $> 吨
        </td>
        <td>
            <$=quality $>
        </td>
        <td>
            <div class="input-group"  style="width: 100%;text-align: left;">
                <input type="text" name="batchNum" class="form-control border-none"  />
                <a href="javascript:void(0);" data-id="<$=id$>" title="选择批号" class="input-group-addon select-batch">...</a>
            </div>
        </td>
        <td>
                -
        </td>
        <td style="padding: 1px  8px;">
            <input type="hidden" value="<$=id$>" name="orderIds"/>
            <input type="hidden" value="<$=actualPrice$>" name="prices"/>
            <input type="text" name="orderNumbers" step="0.001" max="<$=canSendNum $>"
                   class="form-control border-none"
                   style="width: 68px;display: inline-block;" value="<$=canSendNum$>"> 吨
        </td>
        <td>
            <$ if(!(typeof must!='undefined' && must=='true')){
            $><a href="javascript:void(0)" class="btn-delete" data-id="<$=id$>">移除</a>
            <$}$>
        </td>
    </tr>

</script>
<script id="template-order-selected-batch" type="application/xhtml+xml">

    <tr class="class-<$=order.id$>" data-json="<$=JSON.stringify(order)$>">
        <td>
            <$=order.no $>
        </td>
        <td>
            <$=order.canSendNum $> 吨
        </td>
        <td>
            <$=order.quality $>
        </td>
        <td>
            <div class="input-group" style="width: 100%;text-align: left;">
                <$=item.batchNum$>
                <a href="javascript:void(0);" data-id="<$=order.id$>" title="选择批号" class="input-group-addon select-batch">...</a>
            </div>
        </td>
        <td>
            <$=item.numberReceive>0?(floatTool.subtract(item.numberReceive, (floatTool.add(item.numberSending, item.numberSended)))):(floatTool.subtract(item.number,item.numberSending))$> 吨
        </td>
        <td style="padding: 1px  8px;">
            <input type="hidden" value="<$=order.id$>" name="orderIds"/>
            <input type="hidden" value="<$=item.id$>" name="billIds"/>
            <input type="hidden" value="<$=item.quality$>" name="quality"/>
            <input type="hidden" value="<$=order.actualPrice$>" name="prices"/>
            <input type="hidden" value="<$=item.batchNum $>" name="batchNum"/>
            <input type="text" name="orderNumbers" step="0.001" max="<$=order.canSendNum $>"
                   class="form-control border-none"
                   style="width: 68px;display: inline-block;" value="<$=item.send $>"> 吨
        </td>
        <td>
            <$if(!isCurrent){$>
            <a href="javascript:void(0)" class="btn-delete" data-id="<$=order.id $>">移除</a>
            <$}$>

        </td>
    </tr>
</script>
<script id="template-purchase-bill" type="application/xhtml+xml">
    <$
            list.map(function(item){
            if(selected[item.id]){
            $>
    <tr>
    <td>
        <$=item.batchNum $>
    </td>
    <td>
        <$=item.numberReceive>0?floatTool.subtract(floatTool.subtract(item.numberReceive,item.numberSended),item.numberSending)):item.number  $> 吨
    </td>
    <td>99.9%</td>
    <td>
        <$=item.storeName $>
    </td>
    <td>
        <$=formatDate(item.storeTime) $>
    </td>
    <td style="padding: 1px 8px;">
        <input type="hidden" name="billIds" value="<$=item.id $>"/>
        <input name="billNumbers" type="hidden" class="form-control"
               style="width: 50px;display: inline-block;"
               value="0" max="<$=item.numberReceive>0?floatTool.subtract(item.numberReceive,item.numberSended):item.number  $>"/>
        <div class=" billNumbers form-control disabled"
             style="width: 50px;display: inline-block;"
        >0
        </div>
        吨
    </td>
    <td><a href="javascript:void(0)" class="remove" data-id="<$=item.id$>">移除</a></td>
    </tr>
    <$}})$>
</script>
<title>后台管理系统</title>
</head>
<body class="sub-body">
<%- include('../../common/top-nav.html') %>
<%- include('../../common/page-title.html',{navs:[
{label:'首页',url:'../../main.html'},
{label:'销售管理',url:'javascript:void(0)'},
{label:'订单管理',url:'./index.html'},
{label:'发货',url:'javascript:void(0)'},
]}) %>
<div class="content">
    <form action="" id="form-send">
        <div class="panel panel-default">
            <div class="panel-body">
                <ul class="nav nav-pills">
                    <li role="presentation" class="active"><a href="#">车号</a></li>
                    <li role="presentation"><a href="#">转货权</a></li>
                    <li role="presentation"><a href="#">介绍信</a></li>
                </ul>
                <div style="margin-top: 15px;">
                    <table class="table table-detail table-vstriped type-order" style="border: none !important;">
                        <tr>

                            <td class="td-label">车号：</td>
                            <td class="td-label-value" style="padding: 1px 8px;">
                                <input type="hidden" name="type" value="0">
                                <input name="carId"   class="form-control"/></td>
                            <td class="td-label">提单有效期：</td>
                            <td class="td-label-value" style="padding: 1px 8px;">
                                <input name="expireTime"
                                       class="form-control"/></td>
                            <td class="td-label">备注：</td>
                            <td class="td-label-value" style="padding: 1px 8px;">
                                <input name="remark"
                                       class="form-control"
                                       placeholder="备注"/></td>
                        </tr>
                    </table>
                </div>
                <br/>
                <table class="table table-striped table-none-padding send-order table-bordered">
                    <tr>
                        <th >订单单号</td>
                        <th >可发货数量</th>
                        <th >品质规格</th>
                        <th>批号</th>
                        <th>批号可发货数量</th>
                        <th>批号发货数量</th>
                        <th >操作</th>
                    </tr>
                    <tr>
                        <td style="padding: 0px 8px;" colspan="1">
                            <a href="javascript:void(0)" class="btn btn-primary btn-combine">合并发货</a>
                        </td>
                        <td colspan="10" style="padding: 0 8px;" class="text-right alert-danger">
                            本次合计可发货：<span style="font-family: Verdana;font-size: 20px;color: red;"
                                          class="can-send-total">0</span> 吨 &nbsp;&nbsp;&nbsp;
                            本次合计发货：<span style="font-family: Verdana;font-size: 20px;color: red;"
                                         class="send-total ">0</span> 吨
                        </td>
                    </tr>
                </table>
                <button class="btn btn-danger btn-submit-send" type="submit">发货提交</button>
                <a class="btn btn-default" href="./index.html">返回</a>
            </div>
        </div>
    </form>
</div>
</body>
<!-- build:js ../../scripts/product/order/send.js  -->
<script type="text/javascript" src="./send.js"></script>
<!-- endbuild -->

</html>